package com.webull.information.client.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.webull.framework.mvc.ApiException;
import com.webull.information.client.model.News;
import com.webull.information.client.model.NewsLabel;
import com.webull.information.client.model.parm.NewsParam;
import com.webull.information.client.model.parm.NewsRelType;

/**
 * 新闻接口集合
 *
 * @author chengang
 * @version 1.0
 * @date 16-5-20
 * @time 下午4:31
 * @since JDK 1.8
 */
public interface InfoNewsService {

	/**
	 * 根据urlMd5判断该url是否存在
	 */
	public News getByUrlMd5(String urlMd5) throws ApiException;

	/**
	 * 查询当天新闻标题重复的新闻
	 * 
	 * @param sumMd5
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */

	public News getBySumMd5(String sumMd5, NewsRelType type, Integer targetId, Date time) throws ApiException;

	/**
	 *
	 * @param targetId
	 * @param type
	 * @param newsId
	 * @throws ApiException
	 */

	public void addNewsInfoRel(Integer targetId, NewsRelType type, Integer newsId) throws ApiException;

	/**
	 * 根据地区id列表和标的物类型分页查找新闻列表
	 *
	 * @param regionIds
	 *            *地区id列表 必填
	 * @param tickerType
	 *            *标的物类型 必填
	 * @param currentNewsId
	 *            *分页的起始新闻id 非必填
	 * @param pageSize
	 *            *分页大小 必填
	 * @return
	 */
	public List<News> searchByTickerType(Integer[] regionIds, Integer tickerType, Long currentNewsId, Integer pageSize,
			String lang);

	/**
	 * 获取新闻的标题物类型types
	 *
	 * @param newsId
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public List<Integer> searchTickerTypeByNewsId(Long newsId) throws ApiException;

	/**
	 * 获取新闻，不需要详情
	 *
	 * @param id
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public News getById(Long id) throws ApiException;

	/**
	 * 根据id,
	 *
	 * @param id
	 * @param detail
	 *            是否需要详情
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public News getById(Long id, Boolean detail) throws ApiException;

	/**
	 * 根据tickerId获取新闻信息列表
	 *
	 * @param tickerId
	 * @param currentNewsId
	 * @param pageSize
	 * @return
	 * @author shimingjun
	 * @since 0.1.0
	 */
	public List<News> searchByTickerId(Integer tickerId, Long currentNewsId, Integer pageSize, String lang);

	/**
	 * 根据新闻ID
	 *
	 * @param tickerIds
	 * @param currentNewsId
	 * @param pageSize
	 * @param lang
	 * @return
	 * @since 0.1.0
	 */
	public List<News> searchByTickerIds(Integer[] tickerIds, Long currentNewsId, Integer pageSize, String lang);

	/**
	 * 获取新闻
	 *
	 * @param currentNewsId
	 * @param pageSize
	 * @param lang
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public List<News> searchHomeNewsByLang(Long currentNewsId, Integer pageSize, String lang) throws ApiException;


	/**
	 *
	 * @param regionIds
	 * @param currentNewsId
	 * @param pageSize
	 * @param lang
	 * @return
	 */
	public List<News> searchByRegionIds(String regionIds, Long currentNewsId, Integer pageSize, String lang);

	/**
	 * 根据id查找新闻
	 *
	 * @param id
	 *            新闻id
	 * @return 对应的新闻标签对象
	 */
	public List<NewsLabel> searchNewLablesById(Long id) throws ApiException;

	/**
	 *
	 * @param ids
	 * @return
	 * @throws ApiException
	 */
	public Map<Long, List<NewsLabel>> searchNewLablesByIds(Long[] ids) throws ApiException;

	/**
	 * 新增targetId和news详情及关联
	 *
	 * @param targetId
	 * @param type
	 * @param news
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public Long bindNewsRecord(Integer targetId, NewsRelType type, News news) throws ApiException;

	/**
	 * 根据parm获取新闻列表
	 *
	 * @param newsParam
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public List<News> searchNewsByParm(NewsParam newsParam) throws ApiException;

	public Integer countNewsByParm(NewsParam newsParam) throws ApiException;

	/**
	 * 根据新闻id删除新闻
	 *
	 * @param id
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public void delById(Long id) throws ApiException;

	/**
	 * 更新新闻
	 *
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public News update(News news) throws ApiException;

	/**
	 * 分页查询已有新闻
	 *
	 * @param lastId
	 * @param pageSize
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public List<News> queryPaging(Long lastId, Integer pageSize) throws ApiException;

	/**
	 * 根据新闻id查询关联的标的物
	 *
	 * @param id
	 * @return
	 * @throws ApiException
	 * @date 2016年8月19日 上午11:35:22
	 */
	public List<Integer> getTickerIdByNewId(Integer id) throws ApiException;

	/**
	 * 根据新闻ID查询货币
	 *
	 * @param id
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public List<Integer> searchCurrencyIdByNewId(Integer id) throws ApiException;

	/**
	 * 根据新闻ID查询期货群组
	 *
	 * @param id
	 * @return
	 * @throws ApiException
	 * @since 0.1.0
	 */
	public List<Integer> searchFutrueGroupIdByNewId(Integer id) throws ApiException;

	/**
	 * 根据货币Id获取关联新闻ID列表(提供分页功能，根据最后坐标,依次往后返回指定数量数据)
	 *
	 * @param currencyId
	 * @param currentNewsId
	 * @param pageSize
	 * @return
	 * @author shimingjun
	 * @since 0.1.0
	 */
	public List<News> searchByCurrencyIds(Integer[] currencyId, Long currentNewsId, Integer pageSize, String lang)
			throws ApiException;

	/**
	 *
	 * @param groupsId
	 * @param currentNewsId
	 * @param pageSize
	 * @param lang
	 * @return
	 * @throws ApiException
	 */
	public List<News> searchByFuturesId(Integer groupsId, Long currentNewsId, Integer pageSize, String lang)
			throws ApiException;

	public List<Integer> searchRelTickerIds(Long newsId) throws ApiException;

	public List<Integer> searchAssocNewsIds(Integer newsId) throws ApiException ;

	public String existLangChain_HomePage(List<String> langs);

	public String existLangChain_tickerIds(List<String> langs, List<Integer> tickerIds);

	public String existLangChain_futrueIds(List<String> langs, Integer futrueId);

	public String existLangChain_currencyIds(List<String> langs, List<Integer> currencyId);

	public String existLangChain_tickTypes(List<String> langs, Integer tickerType, List<Integer> regionIds);
}
